package com.jobjoin.jobjoin.user.controller;


import com.jobjoin.jobjoin.common.util.R;
import com.jobjoin.jobjoin.user.entity.AuthRole;
import com.jobjoin.jobjoin.user.service.AuthRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  角色权限表 前端控制器
 * </p>
 *
 * @author WinsomeC
 * @since 2021-04-18
 */
@RestController
@RequestMapping("/user/auth-role")
public class AuthRoleController {
    @Autowired
    private AuthRoleService authRoleService;

    @PostMapping("/addAuthRole")
    public R addAuthRole(AuthRole authRole){
        boolean save = authRoleService.save(authRole);
        if(save){
            return R.ok();
        }else{
            return R.error();
        }
    }
    @GetMapping
    public R getAuthRole(){
        List<AuthRole> list = authRoleService.list(null);
        return R.ok().data("items",list);
    }

    @DeleteMapping("{id}")
    public boolean deleteAuthRoleById(@PathVariable String id){
        boolean b = authRoleService.removeById(id);
        return b;
    }
}

